package com.sync.utils.common.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName:ResultCodeEnum
 * Package:com.ywf.myproject.common.result
 * Description:
 *
 * @Date:2021/2/28 11:01
 * @Author:YWF
 */
public enum ResultCodeEnum {

    SUCCESS(20000,"成功"),
    UNKNOWN_ERROR(-20000,"未知错误"),
    PARAM_ERROR(-20001,"参数校验错误"),
    NULL_POINT(-20002,"空指针异常"),
    HTTP_CLIENT_ERROR(-20003,"Http状态码错误"),
    HTTP_UNKNOW_HOST(-20004,"未知主机"),
    METHOD_NOT_SUPPORT(-20005,"请求方法不支持"),
    REQUEST_BODY_DATA_ERROR(-20006,"请求body数据缺失或错误"),
    ERROR_CODE_BIZ(-20007,"工具类业务调用异常"),
    ERROR_BAD_SQL(-20007,"数据库SQl执行异常"),

    TOKEN_UN_VAILABLE(-20007,"TOKEN校验失败"),
    USER_NOT_LOGIN(-20008,"用户未登录或Token已过期"),
    APPKEY_NOT_COMPLETE(-20009,"APPKEY缺失，请授权"),
    PARAM_NOT_COMPLETE(-20010,"请求头参数缺失"),
    APP_VERSION_IS_INVALID(-20010,"版本号信息无效"),
    APPID_IS_INVALID(-20010,"开发者账号无效"),
    REQUEST_SOURCE_INVALID(-20011, "请求来源无效"),
    PARAM_IS_BLANK(-20012, "参数为空"),
    PARAM_TYPE_BIND_ERROR(-20013, "参数类型错误"),
    REQUEST_TIME_INVALID(-20014, "请求时间无效"),
    REQUEST_TIME_OUT(-20015, "请求过期，请重新请求"),
    TOKEN_ERROR(-20015, "token无效"),
    SIGN_ERROR(-20016, "签名信息错误"),
    NO_REPEAT_REQUEST(-20017, "请不要重复提交"),
    REDIS_SERVICES_NOT_START(-20017, "Redis为获取到连接池"),
    TOKEN_PARAM_IS_EMPTY(-20018, "无token，请重新登录"),

    /*用户错误*/
    USER_NOT_EXISTS(-20009,"用户未注册"),
    PWD_ERROR(-20020,"用户名或密码错误"),
    SYNC_REQUEST_TIMEOUT(-20021,"长轮询异步请求超时"),

    RESULT_NULL(-20021,"查询结果数据为空"),

    ;

    private Boolean success;

    private Integer code;

    private String msg;

    ResultCodeEnum(Integer code,String msg){
        this.code = code;
        this.msg = msg;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    //校验重复的code值
    public static void main(String[] args) {
        ResultCodeEnum[] ApiResultCodes = ResultCodeEnum.values();
        List<Integer> codeList = new ArrayList<Integer>();
        for (ResultCodeEnum ApiResultCode : ApiResultCodes) {
            if (codeList.contains(ApiResultCode.code)) {
                System.out.println(ApiResultCode.code);
            } else {
                codeList.add(ApiResultCode.getCode());
            }
        }
    }

}
